<template>
    <div>
        账号：<input type="text" v-model="username" @blur="uui">{{error_name}}
        密码：<input type="text" v-model="password">
        <input type="button" value="登录" @click="bind">
        <a href="https://api.weibo.com/oauth2/authorize?client_id=77340564&redirect_uri=http://127.0.0.1:8080/lugege">微博三方登录</a>    
    </div>
</template>

<script>
export default {
    data(){
        return{
            username:'',
            password:'',
            error_name:''
        }
    },
    methods:{
        bind(){
            const data={
                'username':this.username,
                'password':this.password,
                'email':this.email
            }
            this.axios.post('/weibo1/',data).then(resp=>{
                console.log(resp.data)
                if(resp.data.code==200){
                    alert('登陆成功')
                }else{
                    alert('登陆失败')
                }
            }).catch(error=>{
                console.log(error.response)
            })
        },
        uui(){
            const re = /^\w{2,8}$/
            if(re.test(this.username)){
            this.error_name = '√'
            }else{
            this.error_name = '请输入2-8个字节符'
            }
        }
    }
}
</script>

<style>

</style>